<?php

class OnSite {
	
	
	public static function time_on_site($re){
	$marker = time();
	$on = $marker-$re;
	
	switch ($on){
		case $on>31536000: $now=$on/31536000; $time = " years"; $k = explode('.',$now); $nn = $k[1]; $now = $k[0].$time;
		case $on>2592000: if (!$nn){$now=$on/2592000; 
									$time = " month "; 
									$k = explode('.',$now); 
									$nn = $on - ($k[0]*2592000);
									$now = $k[0].$time;
									}
						  else {$nn=$nn/2592000; 
								$time = " month ";
								$k = explode('.',$now); 
						  		$now.= $k[0].$time;
						  		unset($nn);
						  		break;		
						  }
		case $on>604800: if (!$nn){ $now=$on/604800; 
									$time = " weeks "; 
									$k = explode('.',$now); 
									$nn = $on - ($k[0]*604800);
									$now = $k[0].$time;
									}
						  else {$nn=$nn/604800; 
								$time = " weeks ";
								$k = explode('.',$nn); 
						  		$now.= $k[0].$time;
						  		unset($nn);
						  		break;
						  }
		case $on>86400: if (!$nn){  $now=$on/86400; 
									$time = " days "; 
									$k = explode('.',$now); 
									$nn = $on - ($k[0]*86400);
									$now = $k[0].$time;
									}
						  else {$nn=$nn/86400; 
								$time = " days ";
								$k = explode('.',$nn); 
						  		$now.= $k[0].$time;
						  		unset($nn);
						  		break;
						  }
		case $on>3600: if (!$nn){   $now=$on/3600; 
									$time = " hour "; 
									$k = explode('.',$now); 
									$nn = $on - ($k[0]*3600);
									$now = $k[0].$time;
									}
						  else {$nn=$nn/3600; 
								$time = " hour ";
								$k = explode('.',$nn); 
						  		$now.= $k[0].$time;
						  		unset($nn);
						  		break;
						  }
		case $on>60: if (!$nn){     $now=$on/60; 
									$time = " minuts "; 
									$k = explode('.',$now); 
									$nn = $on - ($k[0]*60);
									$now = $k[0].$time;
									}
						  else {$nn=$nn/60; 
								$time = " minuts ";
								$k = explode('.',$nn); 
						  		$now.= $k[0].$time;
						  		unset($nn);
						  		break;
						  }
		default: $now = 'created'; break;
	}
	return $now;
	}
}


?>